<script type="application/javascript">
	function check_pass(){
		var pass=document.getElementById("txtpass").value;
		var pass_confirm=document.getElementById("txtconfirm").value;
		if(pass != pass_confirm){
			alert("Password is not match...!");
			document.getElementById("txtpass").focus();
			document.getElementById("Submit").disabled=true;
			document.getElementById("Submit").style.backgroundColor("#bbbbdd");
		}else{
			document.getElementById("Submit").disabled=false;
		}
	}
</script>
<?php 
	$fullName = $userLog = $email="";
	//check when insert or update
	if(isset($_REQUEST['control'])){
		
		$fullName=escapeValue($_POST['txtfullName']);
		$userLog=escapeValue($_POST['txtuserLog']);
		$email=escapeValue($_POST['txtemail']);
		$pass=$_POST['txtpass'];
		$confirm=$_POST['txtconfirm'];
		if($pass!="" AND $confirm!=""){
			$pass=md5($pass);
			$confirm=md5($confirm);
		}
		if($pass!=$confirm){
			errorMessage("Password is not match...!");
		}else{
			include("user_verify.php");
		}
	}
	// Select user info to fill in control
	if(isset($_REQUEST['user_id'])){
		$where=array("user_id" => getUserId());
		$data = get("tbl_user",$where);
		$user_id=$data['0']['user_id'];
		$fullName=$data[0]['full_name'];
		$userLog = $data[0]['user_login'];
		$email = $data[0]['email'];
		$control = "change&user_id=".$user_id;			
	}
?>
<div class="action">
    <div class="icon_edit"></div>
    <div class="management">User Change Password</div> 
</div>
<div class="sms">
  <?php 
  if(isset($_REQUEST['msgStatus'])){
      echo $_REQUEST['msgStatus'];
  }else{echo @$errors;}
  ?>
</div>
<div style="clear:both"	></div>
<form class="form" id="form1" name="form1" action="index.php?page=home&action=user_change_pass&control=<?php echo $control;?>"  method="post" >
    <table class="bordered" width="770">
    	<tr>
		<tr>
			<td>
            	<input type="hidden" name="txtuser_id" value="<?php echo getUserId();?>"  />
            	<label>Full Name:</label>
            </td> 
            <td><?php echo $fullName ?></td>
            <input type="hidden" name="txtfullName" value="<?php echo getUserId();?>" />
		</tr>
        <tr>
        	<td>
            	<label>User Log:</label> 
            </td>
            <td><?php echo $userLog ?></td>
            <input type="hidden" name="txtuserLog" value="<?php echo $userLog ?>" />
        </tr>
        <tr>
        	 <td >
            	<label>Email:</label>
            </td>
            <td><?php echo $email ?></td>
            <input type="hidden" name="txtemail" value="<?php echo $email ?>"  />
        </tr>
        <tr>
			<td>
            	<label><span class="red">*</span>Password:</label>
            </td>
            <td><input type="password" id="txtpass"  name="txtpass" value="" class="input req-min" minlength="1" /></td>
		</tr>
         <tr>
			<td>
            	<label><span class="red">*</span>Confirm:</label>
            </td>
            <td><input type="password" id="txtconfirm" name="txtconfirm" value="" class="input req-min" minlength="1" /></td>
		</tr>
		<tr>
        	<td></td>
			<td >
                <input class="bg_btn_ok" type="submit"  name="Submit" id="Submit" value="Update" />&nbsp; 
                <input type="button" class="bg_btn_cancel" name="btnCancel" value="Cancel" onclick="redirect('index.php?page=home&action=home')" />
            </td>
		</tr>
	</table>
</form>